const ajax = (_url, _method = 'GET', _data = {}, _ctype = 'application/json') => {
    return new Promise((reslove, reject) => {
        let xhr = new XMLHttpRequest()
        xhr.open(_method, `http://localhost:3000/${_url}`)
        xhr.setRequestHeader('Content-Type', _ctype)
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4) {
                let response = JSON.parse(xhr.responseText)
                if (xhr.status >= 200 && xhr.status < 300) {
                    reslove(response)
                } else {
                    reject(response.meta)
                }
            }
        }
        xhr.send(JSON.stringify(_data))
    })
}